import { EntitySchema } from '@mikro-orm/core';

export class LeOrderGoods {
  id!: string;
  orderSn!: string;
  goodsId!: string;
  goodsSn?: string;
  goodsName!: string;
  goodsImage!: string;
  goodsParamKey!: string;
  goodsParam!: string;
  goodsPrice!: string;
  goodsCostPrice!: string;
  goodsWeight!: string;
  goodsNumber: number = 1;
  totalAmount!: string;
  payAmount!: string;
  afterSales: boolean = false;
  createdTime!: string;
  updatedTime?: string;
  deletedTime?: string;
  isDeleted: boolean = false;
  isEvaluate: boolean = false;
  showGoodsParam!: string;
  couponReduced!: string;
  goodsScore!: string;
  scoreAmount?: string;
  promoterReduced!: string;
}

export const LeOrderGoodsSchema = new EntitySchema({
  class: LeOrderGoods,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    orderSn: { type: 'string', length: 50, index: '订单编号' },
    goodsId: { type: 'string', columnType: 'bigint', index: '商品id' },
    goodsSn: { type: 'string', length: 50, nullable: true },
    goodsName: { type: 'string', length: 100 },
    goodsImage: { type: 'string', length: 255 },
    goodsParamKey: { type: 'string', length: 255 },
    goodsParam: { type: 'string', length: 255 },
    goodsPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    goodsCostPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    goodsWeight: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    goodsNumber: { type: 'number', default: 1 },
    totalAmount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    payAmount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    afterSales: { type: 'boolean', default: false },
    createdTime: { type: 'string', columnType: 'bigint' },
    updatedTime: { type: 'string', columnType: 'bigint', nullable: true },
    deletedTime: { type: 'string', columnType: 'bigint', nullable: true },
    isDeleted: { type: 'boolean', default: false },
    isEvaluate: { type: 'boolean', default: false },
    showGoodsParam: { type: 'string', length: 255 },
    couponReduced: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    goodsScore: { type: 'string', columnType: 'bigint', defaultRaw: `0` },
    scoreAmount: { type: 'string', columnType: 'bigint', nullable: true, defaultRaw: `0` },
    promoterReduced: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
  },
});
